import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:icooker/pages/details/meail_detail_v1.dart';
import 'package:icooker/pages/details/meail_detail_v2.dart';
import 'package:icooker/pages/main/page_main.dart';
import 'package:icooker/pages/payer/jcchewievideo_player.dart';
import 'package:icooker/pages/splash/guide_page.dart';
import 'package:icooker/pages/splash/page_splash.dart';
import 'package:icooker/pages/webview/webview.dart';

final routers = {
  '/': (context) => GuidePage(),
  '/splash': (context) => SplashPage(),
  '/main': (context) => MainPage(),
  '/webview': (context, {args}) => WebViewPage(),
  '/details': (context, {args}) => MetailsDetailV1(),
  '/details2': (context, {args}) => MetailsDetailV2(),
  '/videoplayer': (context, {args}) => JCChewieVideoPlayer(),
};

var onGenerateRoute = (RouteSettings settings) {
  var routeName = settings.name;
  Function pageBuilder = routers[routeName]!;
  if (pageBuilder != null) {
    if (settings.arguments != null) {
      return MaterialPageRoute(
          builder: (context) =>
              pageBuilder(context, arguments: settings.arguments));
    } else {
      return MaterialPageRoute(builder: (context) => pageBuilder(context));
    }
  }
};
